/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.DragonPokerServer;

import java.net.ServerSocket;
import java.net.Socket;
import org.Comunicator.Global;
import org.Comunicator.ManageMessages;
import org.DragonPokerServer.Thread.ThreadUser;

/**
 *
 * @author gonçalo.margalho
 */
public class Server  extends Thread {

    @Override
    public void run() {
         try {
            //Faccio partire il Thread per la gestione e l'invio dei messaggi!
            new ManageMessages().start();

            ServerSocket srv = new ServerSocket(1111);
            System.out.println("Parte Server!!!");
            while (true) {
                Socket s = srv.accept();
                System.out.println("----->SERVER: Nuovo Utente!!!");
                ThreadUser tu = new ThreadUser(s);
                Global.users.add(tu);
                tu.start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
